package Day03.HomeWork;

import Day02.HomeWork.User;
import java.io.*;

public class Demo1 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        File file=new File(".");//获取路径
        if(file.isDirectory()){//判断是否为文件
            FileFilter filter = pathname -> pathname.getName().endsWith(".obj");//过滤留下需要的
            File[] subs=file.listFiles(filter);//转化为一个数组
        for (int i=0;i< subs.length;i++){
            FileInputStream fis=new FileInputStream(subs[i]);//获取每个下标的具体值作为入境传入输入流
        ObjectInputStream ois=new ObjectInputStream(fis);//对象输入流
        User user=(User)ois.readObject();//对象反序列化
        System.out.println(user);//输出每个对象
        ois.close();//关闭数据流
        }
        }
    }
}
